import {calc} from 'a-calc/es';

export default {
    data() {
        return {
            clbgSubtotal: '',

            form: {

                clbgChargingStandard: '',
                clbgCustody: '',
                clbgGoods: '',
                clbgSubtotal: 0,
            }
        }
    },
    watch: {
        // 车辆保管费 - 收费标准
        'form.clbgChargingStandard'(val) {

            this.getCheLiangBaoguanfei()
        },
        // 车辆保管费 - 载有货物
        'form.clbgGoods'() {
            this.getCheLiangBaoguanfei()
        },
        // 车辆保管费 - 保管天数
        'form.clbgCustody'(val) {
            if (val) {
                this.form.clbgGoods = '否'
            }
            this.getCheLiangBaoguanfei()
        },
    },
    methods: {
        getCheLiangBaoguanfei(){
            if(this.form.clbgCustody){
                this.clbgSubtotal = calc(`
				${this.form.clbgChargingStandard || 0}
				* ${this.form.clbgCustody || 0}
				* (${this.form.clbgGoods === '是'?1.5:1})
			`)
            }else{
                this.form.clbgGoods = ''
                // this.form.clbgChargingStandard = '';
                this.clbgSubtotal = ''
            }


        },
		cheliangbaoguanCancel(){
			if(!+this.clbgSubtotal){
				this.form.clbgCarType = ""
				this.form.clbgChargingStandard = ""
				this.form.clbgCustody = ""
				this.form.clbgGoods = ""
				this.form.clbgSubtotal = ""
			}
		}
    },
}
